home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / modelers / chmsthtc / chmsthtc.lzh / Chemesthetics / Source / Source.LZH / pdomain / exlibsrc.c next >
Encoding:
C/C++ Source or Header  |  1991-10-23  |  5.7 KB  |  246 lines

  1. /* exlibsrc.c (usually archived in a linker library) */
  2.  
  3. #include <intuition/intuition.h>
  4. #include <proto/graphics.h>
  5. void Block(win,col,x1,y1,width,height)         /* Block zeichnen */
  6. struct Window *win;
  7. int col,x1,y1,width,height;
  8. {
  9.   struct RastPort *RP;
  10.   if(width==0 || height ==0) return;
  11.   RP=win->RPort;
  12.   SetDrMd(RP,JAM1);
  13.   SetAPen(RP,col);
  14.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  15. }
  16. #include <intuition/intuition.h>
  17. #include <proto/graphics.h>
  18.  
  19. void Box(win,col1,col2,x1,y1,width,height)   /*  leere Box mit Rahmen zeichnen */
  20. struct Window *win;
  21. int col1,col2,x1,y1,width,height;
  22. {
  23.   struct RastPort *RP;
  24.   if(width==0 || height==0) return;
  25.   RP=win->RPort;
  26.   SetDrMd(RP,JAM1);
  27.   SetAPen(RP,col1);
  28.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  29.   SetAPen(RP,col2);
  30.   RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
  31. }
  32. #include <intuition/intuition.h>
  33. #include <proto/graphics.h>
  34. #include <proto/intuition.h>
  35. void Cls(win,col)                  /* Bildschirm l÷schen in Farbe col */
  36. struct Window *win;
  37. int col;
  38. {
  39.   Move(win->RPort,0,0);       /* Rastport in die obere linke Ecke setzen */
  40.   SetRast(win->RPort,col);
  41.   RefreshWindowFrame(win);
  42.   RemakeDisplay();
  43. }
  44.  
  45. #include <intuition/intuition.h>
  46. #include <proto/graphics.h>
  47.  
  48. void Ellipse(win,col,x,y,rx,ry)                 /* Ellipse zeichnen */
  49. struct Window *win;
  50. int col,x,y,rx,ry;
  51. {
  52.   struct RastPort *RP;
  53.   RP=win->RPort;
  54.   SetDrMd(RP,JAM1);
  55.   SetAPen(RP,col);
  56.   DrawEllipse(RP,x,y,rx,ry);
  57. }
  58. /* oeffnet CONSOLE-Window f. (Revision-)Messages */
  59.  
  60. #include <exec/types.h>
  61.  
  62. extern char ProgId[],Version[];
  63. extern int Revision;
  64. extern char UserId[],Date[];
  65.  
  66. int OpenRevWin(size)
  67. char *size;
  68. {
  69.   int window;
  70.   char Str1[180],Str2[190];
  71.   window=open(size,2,0);
  72.   if(window==-1)
  73.     return(-1);
  74.   sprintf(Str1,"%s %s - Revision %d\n\n",ProgId,Version,Revision);
  75.   sprintf(Str2,"latest update by: %s  %s\n\n",UserId,Date);
  76.   WrConWin(window,Str1);
  77.   WrConWin(window,Str2);
  78.   return(window);
  79. }
  80.  
  81. #include <intuition/intuition.h>
  82. #include <proto/graphics.h>
  83.  
  84. void Pixel(win,col,x,y)               /* Punkt setzen */
  85. struct Window *win;
  86. int col,x,y;
  87. {
  88.   struct RastPort *RP;
  89.   RP=win->RPort;
  90.   SetDrMd(RP,JAM1);
  91.   SetAPen(RP,col);
  92.   WritePixel(RP,x,y);
  93. }
  94. #include <intuition/intuition.h>
  95. #include <proto/intuition.h>
  96. #include <proto/graphics.h>
  97.  
  98. Print(win,text,col1,col2,xpos,ypos)      /* Ausgabe von Text */
  99. struct Window *win;
  100. char *text;
  101. int col1,col2,xpos,ypos;
  102. {
  103.   int dx=4,width=win->GZZWidth;
  104.   struct RastPort *RP;
  105.  
  106. /*  if((width-strlen(text)*8) < 0) return; */   /* Text zu lang */
  107.   RP=win->RPort;
  108.   SetDrMd(RP,JAM2);
  109.   SetAPen(RP,col1);
  110.   SetBPen(RP,col2);
  111.   if (win->Flags & GIMMEZEROZERO) dx=0;
  112.   if(xpos == -1) xpos=(width-strlen(text)*8)/2+dx;   /* zentriert */
  113.   if(xpos == -2) xpos=width-strlen(text)*8+dx;       /* rechtsbⁿndig */
  114.   Move(RP,xpos,ypos);
  115.   Text(RP,text,strlen(text));
  116. }
  117. /***************************************************************************
  118. * ReqBlock.c: zeichnet ein Viereck in einen Requester(!!)                  *
  119. *                                       *
  120. * created: 1990 Mtwx                               *
  121. * updated: 06-Aug-91 Mtwx                           *
  122. ***************************************************************************/
  123.  
  124. /* ------------------------------- includes ----------------------------- */
  125.  
  126. #include <intuition/intuition.h>
  127. #include <proto/graphics.h>
  128.  
  129. /* ------------------------------- routines ----------------------------- */
  130.  
  131. void ReqBlock(req, col, x1, y1, width, height)
  132. struct Requester *req;
  133. int col, x1, y1, width, height;
  134. {
  135.   struct RastPort *RP;
  136.  
  137.   if (width == 0 || height == 0)
  138.     return;
  139.   RP = req->ReqLayer->rp;
  140.   SetDrMd(RP, JAM1);
  141.   SetAPen(RP, col);
  142.   RectFill(RP, x1, y1, x1 + width - 1, y1 + height - 1);
  143. }
  144. #include <intuition/intuition.h>
  145. ReqBox(req,col1,col2,x1,y1,width,height)   /*  leere Box mit Rahmen im
  146.                            Requester zeichnen */
  147. struct Requester *req;
  148. int col1,col2,x1,y1,width,height;
  149. {
  150.   struct RastPort *RP;
  151.   if(width==0 || height==0) return;
  152.   RP=req->ReqLayer->rp;
  153.   SetDrMd(RP,JAM1);
  154.   SetAPen(RP,col1);
  155.   RectFill(RP,x1,y1,x1+width-1,y1+height-1);
  156.   SetAPen(RP,col2);
  157.   RectFill(RP,x1+1,y1+1,x1+width-2,y1+height-2);
  158. }
  159.  
  160.  
  161. #include <intuition/intuition.h>
  162. #include <proto/graphics.h>
  163. void ReqPrint(req,text,col1,col2,xpos,ypos)      /* Ausgabe von Text */
  164. struct Requester *req;
  165. char *text;
  166. int col1,col2,xpos,ypos;
  167. {
  168.   int width=req->Width;
  169.   struct RastPort *RP;
  170.  
  171.   RP=req->ReqLayer->rp;
  172.   SetDrMd(RP,JAM2);
  173.   SetAPen(RP,col1);
  174.   SetBPen(RP,col2);
  175.   if(xpos == -1) xpos=(width-strlen(text)*8)/2;   /* zentriert */
  176.   if(xpos == -2) xpos=width-strlen(text)*8;       /* rechtsbⁿndig */
  177.   Move(RP,xpos,ypos);
  178.   Text(RP,text,strlen(text));
  179. }
  180. #include <intuition/intuition.h>
  181. #include <proto/graphics.h>
  182.  
  183. void Shadow(win,text,txtc,shdwc,xpos,ypos)     /* Ausgabe von Text */
  184. struct Window *win;                  /* mit Schatten      */
  185. char *text;
  186. int txtc,shdwc,xpos,ypos;
  187. {
  188.   int dx=4,width=win->GZZWidth;
  189.   struct RastPort *RP;
  190.  
  191.   RP=win->RPort;
  192.   SetDrMd(RP,JAM1);
  193.   SetAPen(RP,shdwc);
  194.   if(win->Flags & GIMMEZEROZERO) dx=0;
  195.   if(xpos==-1) xpos=(width-strlen(text)*8)/2+dx;
  196.   if(xpos==-2) xpos=width-strlen(text)*8+dx;
  197.   Move(RP,xpos+1,ypos+1);
  198.   Text(RP,text,strlen(text));
  199.   SetAPen(RP,txtc);
  200.   Move(RP,xpos,ypos);
  201.   Text(RP,text,strlen(text));
  202. }
  203. int strpos(s1,s2)
  204. char *s1,*s2;
  205. {
  206.   register int i;
  207.   int n,pos=0,flag=0;
  208.  
  209.   if(strlen(s2) > strlen(s1)) return -1;
  210.   for(i=0;i<strlen(s1)-strlen(s2)+1;i++)
  211.   {
  212.     n=strncmp(&s1[i],s2,strlen(s2));
  213.     if(n==0)
  214.     {
  215.       pos=i;
  216.       flag=1;
  217.       break;
  218.     }
  219.   }
  220.   if(!flag) pos=-1;
  221.   return pos;
  222. }
  223. #include <exec/types.h>
  224.  
  225. #define EXIST 0
  226. #define EXECUTE 1
  227. #define WRITE 2
  228. #define READ 4
  229.  
  230. BOOL TestFile(file)
  231. char *file;
  232. {
  233.   int Erfolg;
  234.   Erfolg=access(file,EXIST);
  235.   if(Erfolg==0) return (TRUE);
  236.   else return (FALSE);
  237. }
  238.  
  239.  
  240. void WrConWin(win,text)
  241. int win;
  242. char *text;
  243. {
  244.   write(win,text,strlen(text));
  245. }
  246.